package edu.bit.water.service;

import edu.bit.water.dao.GalleryComponentDao;
import edu.bit.water.entity.GalleryComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GalleryComponentService {
    
    @Autowired
    private GalleryComponentDao galleryComponentDao;
    
    //增加控件
    public int insert(GalleryComponent galleryComponent){
        Integer id = galleryComponentDao.getMaxId();
        if(id == null) {
            galleryComponent.setId(0);
        }else {
            galleryComponent.setId(id + 1);
        }
        return galleryComponentDao.insert(galleryComponent);
    };

    //删除流程图数据
    public int deleteBatchIds(List<Integer> id){
        for (int i : id) {
            int q = galleryComponentDao.deleteBatchIds(i);
            if (q == 0)
                return 0;
        }
        return 1;
    };

    //修改流程图数据
    public int updateById(GalleryComponent galleryComponent){
        return galleryComponentDao.updateById(galleryComponent);
    };

    //查询所有流程图数据
    public List<GalleryComponent> selectList(String companyName){
        return galleryComponentDao.selectList(companyName);
    };
    
}
